package org.example.RabbitListener;

import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

@Component
public class SpringRabbitListener 
{
	//基于注解来声明队列和交换机，并且绑定
	@RabbitListener(bindings = {
			@QueueBinding(
					value = @Queue(value = "direct.queue1", durable = "true"),	//设置队列,并且持久化
					exchange = @Exchange(value = "xiri.direct",type = ExchangeTypes.DIRECT),	//设置交换机和类型
					key = {"key1"}	//设置路由
			)
	})
	public void listener1(Map mes) throws InterruptedException {
		System.out.println("消费者1接受消息："+mes);
	}
}
